1 CLS : PRINT : PRINT : PRINT
  PALETTE 0, 8: s = 1: y = 1: x = 1
  PRINT TAB(30); "KCCK Designs Presents:": SLEEP 1
  CLS : PRINT : PRINT : PRINT : COLOR 10, 0, 8: PRINT TAB(38); "Castle": COLOR 7, 0, 8
  PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT TAB(35); "developed by Ken Capaul and Chris Kugler"
  PRINT TAB(35); "(C) copyright 1995, KCCK Designs"
  PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : PRINT : INPUT "Do you want instructions"; I$
  IF yes$ = "Y" OR I$ = "y" OR I$ = "YES" OR I$ = "yes" THEN GOSUB 390
50 CLS : PRINT : PRINT "You are in the castle antechamber.  There are exits to the north and east."
55 INPUT c$
   IF c$ = "N" OR c$ = "n" THEN GOTO 80
   IF c$ = "E" OR c$ = "e" THEN GOTO 170
   IF c$ = "S" OR c$ = "s" THEN GOSUB 9020
   IF c$ = "W" OR c$ = "w" THEN GOSUB 9020
   IF c$ = "USE KEY" OR c$ = "use key" THEN GOSUB 530
   IF c$ = "" THEN GOTO 55
   IF c$ = "I" OR c$ = "i" THEN GOSUB 9040
   IF c$ = "QUIT" OR c$ = "quit" THEN GOSUB 8000
   GOTO 55
80 CLS : PRINT : PRINT "You are in the throne room.  There are exits to the west and the south."
85 INPUT a$
   IF a$ = "W" OR a$ = "w" THEN GOTO 120
   IF a$ = "S" OR a$ = "s" THEN GOTO 50
   IF a$ = "USE KEY" OR a$ = "use key" THEN GOSUB 530
   IF a$ = "" THEN GOTO 85
    IF a$ = "N" OR a$ = "n" THEN GOSUB 9020
    IF a$ = "E" OR a$ = "e" THEN GOSUB 9020
    IF a$ = "I" OR a$ = "i" THEN GOSUB 9040
    IF a$ = "QUIT" OR a$ = "quit" THEN GOSUB 8000
    GOTO 85
120 CLS : PRINT : PRINT "You are in an empty room with no exits, save the one you came in through."
    IF x = 1 THEN PRINT "You see a bronze key laying on the floor."
140 INPUT z$
    IF z$ = "GET KEY" OR z$ = "get key" THEN PRINT "You now have the bronze key."
    IF z$ = "GET KEY" OR z$ = "get key" THEN x = 2
    IF z$ = "USE KEY" OR z$ = "use key" THEN GOSUB 530
    IF z$ = "I" OR z$ = "i" THEN GOSUB 9040
    IF z$ = "GET KEY" OR z$ = "get key" THEN GOTO 140
    IF z$ = "" THEN GOTO 140
    IF z$ = "E" OR z$ = "e" THEN GOTO 160
    IF z$ = "N" OR z$ = "n" THEN GOSUB 9020
    IF z$ = "S" OR z$ = "s" THEN GOSUB 9020
    IF z$ = "W" OR z$ = "w" THEN GOSUB 9020
    IF z$ = "QUIT" OR z$ = "quit" THEN 8000
    GOTO 140
160 GOTO 80
170 CLS : PRINT : PRINT "You are in a room with exits to the north, south, east, and west."
180 INPUT b$
    IF b$ = "W" OR b$ = "w" THEN GOTO 50
    IF b$ = "N" OR b$ = "n" THEN CLS : PRINT : PRINT "As you enter the room, an arrow shoots from the wall, piercing your heart.      You die!": GOTO 7500
    IF b$ = "S" OR b$ = "s" THEN CLS : PRINT : PRINT "As you enter the room, you trigger a floor panel that closes the door behind    you.  To your horror, the walls close in, crushing you.  The End.": GOTO 7500
    IF b$ = "E" OR b$ = "e" THEN CLS : PRINT : PRINT "You are in a room with a bronze door. There are no exits besides the one you    came through."
215 INPUT d$
    IF b$ = "I" OR b$ = "i" THEN GOSUB 9040
    IF b$ = "USE KEY" OR b$ = "use key" THEN GOSUB 530
    IF b$ = "QUIT" OR b$ = "quit" THEN 8000
    IF b$ = "" THEN GOTO 180
    IF d$ = "N" OR d$ = "n" THEN GOSUB 9020
    IF d$ = "S" OR d$ = "s" THEN GOSUB 9020
    IF d$ = "E" OR d$ = "e" THEN PRINT "The door is blocking your way."
    IF d$ = "W" OR d$ = "w" THEN GOTO 170
    IF d$ = "I" OR d$ = "i" THEN GOSUB 9040
    IF d$ = "QUIT" OR d$ = "quit" THEN 8000
    IF d$ = "" THEN GOTO 215
    IF d$ = "OPEN DOOR" OR d$ = "open door" THEN PRINT "It's locked."
    IF d$ = "USE KEY" OR d$ = "use key" OR d$ = "UNLOCK DOOR" OR d$ = "unlock door" THEN GOTO 310
    GOTO 215
310 IF x = 1 THEN GOSUB 530
    IF x = 2 THEN GOTO 331
    GOTO 215
331 PRINT "The door is now unlocked."
    INPUT m$
    IF m$ = "OPEN DOOR" OR m$ = "open door" THEN GOTO 1020
    GOTO 215
390 CLS : PRINT : PRINT "You are trapped in a castle and have to escape.": PRINT
    PRINT "  Commands:"
    PRINT "N - go north"
    PRINT "S - go south"
    PRINT "E - go east"
    PRINT "W - go west"
    PRINT "GET (ITEM) - get (ITEM)"
    PRINT "I - see inventory"
    PRINT "OPEN (ITEM) - open (ITEM)"
    PRINT "USE (ITEM) - use (ITEM)"
    PRINT "QUIT - ends game in progress"
    PRINT : PRINT : PRINT : PRINT "Press any key to continue..."
400 a$ = INKEY$: IF a$ = "" THEN 400
    RETURN
530 IF x < 2 THEN PRINT "You don't have a key."
    IF x > 1 THEN PRINT "Where?"
    RETURN
1020 CLS : PRINT : PRINT "You have just escaped from inside the castle.  You see the castle courtyard to  the south through an open portacullis to the south."
1023 INPUT aa$
     IF aa$ = "N" OR aa$ = "n" THEN GOSUB 9020
     IF aa$ = "E" OR aa$ = "e" THEN GOSUB 9020
     IF aa$ = "W" OR aa$ = "w" THEN GOSUB 9020
     IF aa$ = "S" OR aa$ = "s" THEN GOTO 1035
     IF aa$ = "QUIT" OR aa$ = "quit" THEN GOSUB 8000
     IF aa$ = "I" OR aa$ = "i" THEN GOSUB 9040
     IF aa$ = "" THEN GOTO 1023
     GOTO 1023
1035 CLS : PRINT : PRINT "You are standing in an overgrown courtyard.  A closed portacullis blocks the    entrance to the castle.  You can go west, east, and south."
1036 INPUT cc$
     IF cc$ = "N" OR cc$ = "n" THEN GOSUB 9020
     IF cc$ = "S" OR cc$ = "s" THEN GOTO 1050
     IF cc$ = "E" OR cc$ = "e" THEN GOTO 1060
     IF cc$ = "W" OR cc$ = "w" THEN GOTO 1048
     IF cc$ = "QUIT" OR cc$ = "quit" THEN GOSUB 8000
     IF cc$ = "I" OR cc$ = "i" THEN GOSUB 9040
     IF cc$ = "" THEN GOTO 1036
     GOTO 1036
1048 CLS : PALETTE 0, 4: PRINT : PRINT "A section of the ground gives way underneath your weight.  You fall into a      spiked pit.  You are impaled and die."
     GOTO 7500
1050 CLS : PRINT : PRINT "You are standing next to an old fountain in the center of the garden. Weeds and vines cover the cracked stone.  You can go north, south, east, and west."
1051 INPUT ff$
     IF ff$ = "N" OR ff$ = "n" THEN GOTO 1035
     IF ff$ = "S" OR ff$ = "s" THEN GOTO 1105
     IF ff$ = "E" OR ff$ = "e" THEN GOTO 1075
     IF ff$ = "W" OR ff$ = "w" THEN GOTO 1090
     IF ff$ = "QUIT" OR ff$ = "quit" THEN GOSUB 8000
     IF ff$ = "I" OR ff$ = "i" THEN GOSUB 9040
     IF ff$ = "" THEN GOTO 1051
     GOTO 1051
1060 CLS : PRINT : PRINT "You are standing in the northeast corner of the courtyard."
     x$ = "There is a sword here."
     IF s = 1 THEN PRINT x$
1063 INPUT dd$
     IF dd$ = "N" OR dd$ = "n" THEN GOSUB 9020
     IF dd$ = "E" OR dd$ = "e" THEN GOSUB 9020
     IF dd$ = "W" OR dd$ = "w" THEN GOTO 1035
     IF dd$ = "S" OR dd$ = "s" THEN GOTO 1075
     IF dd$ = "GET SWORD" OR dd$ = "get sword" THEN PRINT "You now have the sword.": s = 2
     IF dd$ = "QUIT" OR dd$ = "quit" THEN GOSUB 8000
     IF dd$ = "I" OR dd$ = "i" THEN GOSUB 9040
     IF dd$ = "" THEN GOTO 1063
     GOTO 1063
1075 CLS : PRINT : PRINT "You are standing in a grove of small trees.  There is a gnome sitting on a stumphere.  You can go north and west."
     IF s = 2 THEN PRINT "The gnome steals your sword and runs off!": s = 1
1078 INPUT gg$
     IF gg$ = "N" OR gg$ = "n" THEN GOTO 1060
     IF gg$ = "S" OR gg$ = "s" THEN GOSUB 9020
     IF gg$ = "E" OR gg$ = "e" THEN GOSUB 9020
     IF gg$ = "W" OR gg$ = "w" THEN GOTO 1050
     IF gg$ = "QUIT" OR gg$ = "quit" THEN GOSUB 8000
     IF gg$ = "I" OR gg$ = "i" THEN GOSUB 9040
     IF gg$ = "" THEN GOTO 1078
     GOTO 1078
1090 CLS : PRINT : PRINT "You are standing on the west side of the courtyard.  There is a guard here.  Youcan go west and south."
     IF y = 1 THEN PRINT "There is a rusty key here."
     g = 1
     IF y = 1 AND s = 2 THEN SLEEP 1: IF y = 1 AND s = 2 THEN PRINT "The guard sees your sharp sword and lets you get the key.  You now have the     rusty key."
     IF s = 2 THEN y = 2
1095 INPUT ee$
     IF ee$ = "N" OR ee$ = "n" THEN GOSUB 9020
     IF ee$ = "S" OR ee$ = "s" THEN GOTO 1120
     IF ee$ = "E" OR ee$ = "e" THEN GOTO 1050
     IF ee$ = "W" OR ee$ = "w" THEN GOSUB 9020
     IF ee$ = "QUIT" OR ee$ = "quit" THEN GOSUB 8000
     IF ee$ = "GET KEY" OR ee$ = "get key" THEN PRINT "The guard blocks your path."
     IF ee$ = "I" OR ee$ = "i" THEN GOSUB 9040
     IF ee$ = "" THEN GOTO 1095
     GOTO 1095
1105 CLS : PRINT : PRINT "You are at the south end of the courtyard.  There is a rusty gate to the south. You can go north and west."
1106 INPUT ii$
     IF ii$ = "USE KEY" OR ii$ = "use key" THEN GOSUB 8100
     IF ii$ = "OPEN GATE" OR ii$ = "open gate" AND y = 3 THEN GOTO 1150
     IF ii$ = "OPEN GATE" OR ii$ = "open gate" AND y < 3 THEN PRINT "The rusty gate is locked.": GOTO 1106
     IF ii$ = "N" OR ii$ = "n" THEN GOTO 1050
     IF ii$ = "S" OR ii$ = "s" THEN PRINT "The gate is blocking your way.": GOTO 1106
     IF ii$ = "E" OR ii$ = "e" THEN GOSUB 9020
     IF ii$ = "W" OR ii$ = "w" THEN GOTO 1120
     IF ii$ = "QUIT" OR ii$ = "quit" THEN GOSUB 8000
     IF ii$ = "I" OR ii$ = "i" THEN GOSUB 9040
     IF ii$ = "" THEN GOTO 1106
     GOTO 1106
1120 CLS : PRINT : PRINT "You are in a garden.  The scent of the poisonous flowers causes you to fall     asleep!"
     s = 1: y = 1
     SLEEP 4
     GOTO 1050
1150 CLS : PRINT : PRINT "You step out of the overgrown courtyard into..."
     PRINT : PRINT TAB(10); "YOU WIN!!"
     PRINT : PRINT : PRINT : PRINT : PRINT "Wait for more games by KCCK Designs."
7500 PRINT : INPUT "Do you want to play again (Y)es or (N)o"; k$: IF k$ = "Y" THEN GOTO 1
     END
8000 INPUT "Do you really want to quit- (Y)es or (N)o"; k$
     IF k$ = "Y" OR k$ = "y" THEN END
     RETURN
8100 IF y = 1 THEN PRINT "The bronze key does not fit in the lock.": RETURN
     IF y = 2 THEN INPUT " -which key"; key$
     IF key$ = "RUSTY" OR key$ = "rusty" OR key$ = "Rusty" THEN 8170
     IF key$ = "BRONZE" OR key$ = "bronze" OR key$ = "Bronze" THEN 8160
     PRINT "You cannot use that command here."
     RETURN
8160 PRINT "The bronze key does not fit in the lock.": RETURN
8170 PRINT "The rusty gate is now unlocked.": y = 3: RETURN
9020 PRINT "You cannot go in that direction."
     RETURN
9040 IF x = 2 THEN PRINT "You have a bronze key."
     IF y = 2 OR y = 3 THEN PRINT "You have a rusty key."
     IF s = 2 THEN PRINT "You are wielding a sword."
     IF x = 1 AND s = 1 AND y = 1 THEN PRINT "You are carrying nothing."
     RETURN

